package osgi_demo;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import osgi_demo_service.SimpleLogService;

public class Activator implements BundleActivator {

	/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
	 */
	ServiceReference helloServiceReference;

	public void start(BundleContext context) throws Exception {
		System.out.println("Hello World!!");

		helloServiceReference= context.getServiceReference(SimpleLogService.class.getName());
		SimpleLogService simpleService =(SimpleLogService)context.getService(helloServiceReference);
		simpleService.log(this.getClass().getName()+" is calling");
		
	}
	
	/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
	 */
	public void stop(BundleContext context) throws Exception {
		System.out.println("Goodbye World!!");
		context.ungetService(helloServiceReference);
	}

}
